package bairui.international.controller.prize.nine;

/**
 * @see bairui.international.controller.prize.nine.WinPage_BaseFilter
 *
 */
class WinPage_Filter

{
	
	/**
	 * 过滤扩展接口
	 */
	static interface FilterExtends {
		com.querydsl.core.types.Predicate gainTitle(
			String title
		);
		com.querydsl.core.types.Predicate gainState(
			bairui.international.model.status.State_Prize state
		);
	}
	
	final static com.querydsl.core.BooleanBuilder query(
		bairui.international.model.domain.jpa.QTB_WinPrize QRoot,
		javax.servlet.http.HttpServletRequest request
		,FilterExtends filterExtends
	) {
		com.querydsl.core.BooleanBuilder query = query(
				QRoot
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("realName"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("nickName"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("phone"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("prizeName"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("userType"), 
						bairui.international.model.type.Type_User.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("finishFlag"), 
						Boolean.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("createTime_start"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					),
				com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("createTime_end"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("finishTime_start"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					),
				com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("finishTime_end"), 
						java.util.Date.class, 
						"yyyy-MM-dd"
					)
			);
			/* comment 附加过滤属性 */
			if(null != request.getParameter("title")){
				query.and(filterExtends.gainTitle(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("title"), 
							String.class, 
							"yyyy-MM-dd"
						)
				));
			}
			if(null != request.getParameter("state")){
				query.and(filterExtends.gainState(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("state"), 
							bairui.international.model.status.State_Prize.class, 
							"yyyy-MM-dd"
						)
				));
			}
	;
		return query;
	}
	
	final static com.querydsl.core.BooleanBuilder query(
		bairui.international.model.domain.jpa.QTB_WinPrize QRoot
	,	String realName
	,	String nickName
	,	String phone
	,	String prizeName
	,	bairui.international.model.type.Type_User userType
	,	Boolean finishFlag
	,	java.util.Date createTime_start,
		java.util.Date createTime_end
	,	java.util.Date finishTime_start,
		java.util.Date finishTime_end
	) {
		com.querydsl.core.BooleanBuilder builder = new com.querydsl.core.BooleanBuilder();
	
		if(null != realName){
			builder.and(QRoot.realName.like("%"+realName+"%"));
		}
		if(null != nickName){
			builder.and(QRoot.nickName.like("%"+nickName+"%"));
		}
		if(null != phone){
			builder.and(QRoot.phone.like("%"+phone+"%"));
		}
		if(null != prizeName){
			builder.and(QRoot.prizeName.like("%"+prizeName+"%"));
		}
		if(null != userType){
			builder.and(QRoot.userType.eq(userType));
		}
		if(null != finishFlag){
			builder.and(QRoot.finishFlag.eq(finishFlag));
		}
		if(null != createTime_start && null != createTime_end){
			builder.and(QRoot.createTime.between(createTime_start, createTime_end));
		}
		if(null != finishTime_start && null != finishTime_end){
			builder.and(QRoot.finishTime.between(finishTime_start, finishTime_end));
		}
		return builder;
	}
	
}
